//
//  CaseTableViewCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/9.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "CaseTableViewCell.h"

@interface CaseTableViewCell ()

@property (nonatomic, strong) UIImageView *headImage;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UILabel *addressLabel;
@property (nonatomic, strong) UILabel *moneyLabel;

@end

@implementation CaseTableViewCell

+ (CaseTableViewCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"CaseTableViewCell";
    CaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[CaseTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

-(void)setCreateAreaDataModel:(CreateAreaDataModel *)createAreaDataModel
{
    _createAreaDataModel = createAreaDataModel;
    
    self.nameLabel.text = createAreaDataModel.design_name;
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:createAreaDataModel.pic] placeholderImage:nil options:SDWebImageRetryFailed];
    self.moneyLabel.text = [NSString stringWithFormat:@"%@元",createAreaDataModel.price];
    self.detailLabel.text = createAreaDataModel.name;
    self.addressLabel.text = createAreaDataModel.address;
}

- (void)createSubView {
    self.headImage = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(15), ScreenX375(140), ScreenX375(78))];
    self.headImage.layer.cornerRadius = ScreenX375(5);
    self.headImage.clipsToBounds = YES;
    self.headImage.image = [UIImage imageNamed:@"头部背景"];
    [self addSubview:self.headImage];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(163), ScreenX375(13), ScreenX375(165), ScreenX375(35))];
    self.nameLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.nameLabel.font = Kfont(14);
    self.nameLabel.numberOfLines = 0;
    self.nameLabel.text = @"公司包装设计 / 商标设计 /LOGO设计";
    [self addSubview:self.nameLabel];
    
    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(163), ScreenX375(60), ScreenX375(165), ScreenX375(16))];
    self.detailLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.detailLabel.font = Kfont(12);
    self.detailLabel.text = @"森林包装设计";
    [self addSubview:self.detailLabel];
    
    self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(163), ScreenX375(80), ScreenX375(130), ScreenX375(14))];
    self.addressLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.addressLabel.font = Kfont(12);
    self.addressLabel.text = @"台州";
    [self addSubview:self.addressLabel];
    
    self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(113), ScreenX375(80), ScreenX375(100), ScreenX375(16))];
    self.moneyLabel.textColor = ThemeColor;
    self.moneyLabel.font = Kfont(14);
    self.moneyLabel.textAlignment = NSTextAlignmentRight;
    self.moneyLabel.text = @"100元";
    [self addSubview:self.moneyLabel];
    
    UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(108) - 0.5, SCREEN_WIDTH - ScreenX375(26), 0.5)];
    line.image = [UIImage imageNamed:@"虚线"];
    [self addSubview:line];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
